var app = getApp()
Page({
    data: {
        data: [],
        enterData:{},         // 入驻状态数据
        ready:false,          // 是否准备重新申请

        margin_id:"",            // 会员id
    },
    // 重新申请
    resetApply(){
        this.setData({
            ready:true
        })
    },
    // 前去支付
    goToPay(){
		wx.showLoading({title: '跳转中'})
        var self = this;
        var margin_id = this.data.enterData.margin_id;
        wx.getStorage({
            key: 'user',
            success: function (res) {
                wx.request({
                    url: app.url.requestUrl + '/pays/menmber',
                    method: 'POST',
                    data: {
                        openid: res.data.openid,
                        token: res.data.token,
                        margin_id: margin_id
                    },
                    success: function (res) {
                        var data = res.data
						wx.hideLoading();
                        if (data.code == 1){
                            wx.navigateTo({
                                url: `../pay-style/pay-style?order_no=${data.data.trade_no}&money=${data.data.money}&order_type=charge_order`,
                            })
                        }else{
							wx.showToast({
								image:"../../img/warning.png",
								title: data.msg,
							})
						}
                    }
                })
            }
        })
    },
    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function(options) {
        var that = this;
        wx.getStorage({
            key: 'user',
            success: function(res) {
                wx.request({
                    url: app.url.requestUrl + '/user/residenceintro',
                    method: 'POST',
                    data: {
                        openid: res.data.openid,
                        token: res.data.token,
                    },
                    success: function(res) {
                        that.setData({
                            data: res.data.data,
                        })
                    }
                })
                wx.request({
                    url: app.url.requestUrl + '/user/check_status',
                    method: 'POST',
                    data: {
                        openid: res.data.openid,
                        token: res.data.token,
                    },
                    success: function (res) {
                        var datas = res.data;
                        if (datas.code == 1){
                            that.setData({
                                enterData: datas.data,
                            })
                        }
                    }
                })
            }
        })
    },
})